<#assign module="partner"/>
<@override name="header">
<link rel="stylesheet" href="${ctx}/assets/css/form.css">
<link rel="stylesheet" href="${ctx}/assets/css/datetimepicker.css">
<link rel="stylesheet" href="${ctx}/assets/css/jquery.Jcrop.css">
<link rel="stylesheet" href="${ctx}/assets/css/scojs.css">
<link rel="stylesheet" href="${ctx}/assets/css/sco.message.css">
<style>
	/* autocomplete */
	div.ac {border: 1px solid #ccc;position: absolute;display: none;overflow: auto;background-color: #ffffff;z-index:998;}
	div.ac > ul {margin-top:10px;padding:0;}
	div.ac > ul > li {height:33px;line-height:33px;cursor:pointer;}
	div.ac > ul > li:hover{background:#eee;}
	div.ac > ul > li > div span {padding-left:15px;}
	div.ac > ul > li > div span em {color:red;font-style: normal;}
</style>
</@override>
<@override name="body">
  <div class="row">
	<form id="submit_form" action="#" class="form-horizontal" method="post">
	  		<input type="hidden" id="categoryAlias" value="${categoryAlias}"/>
	  		<input type="hidden" id="lat"/>
	  		<input type="hidden" id="lng"/>
		    <div class="col-md-6">
			    <div class="col-md-12">
			    <div class="panel panel-default">
					<div class="panel-heading">
						请填写商家基本信息
				    </div>
			    	<div class="panel-body">
		                <div class="form-group">
		                    <div class="col-sm-12">
		                    	<div class="input-group">
		                    		<span class="input-group-addon">商家名称</span>
				            		<input class="form-control" id="name" name="name" type="text"   placeholder="请输入名称" required/>
			                	</div>
			                </div>
		                </div>
	                	<div class="form-group">
		                    <div class="col-sm-12">
		                    	<div class="input-group">
		                    		<span class="input-group-addon">商家电话</span>
				            		<input class="form-control" id="phone" name="phone" type="text"  required/>
			                	</div>
			                </div>
		                </div>
		                <#if intents??>
		                <div class="form-group">
		                    <div class="col-sm-12">
		                    	<div class="input-group">
			                    	<div class="input-group-addon">所属分类:</div>
					            	<select class="form-control" id="intentId" name="intentId"/>
					            	<#list intents as intent>
						                <option value="${intent.id}">${intent.name}</option>
					                </#list>
					            	</select>
			                	</div>
			                </div>
		                </div>
		                </#if>
		                 <div class="form-group">
		                    <label><em>&nbsp;&nbsp;</em>详情介绍:</label>
		                    <div class="col-sm-12">
				            	<textarea class="form-control" cols="20" id="intro" name="intro" rows="15"></textarea>
			                </div>
		                </div>
		                
	                    <div class="col-sm-12">
			                <div class="form-group">
						        <div class="col-sm-2" style="width:12%;" >
			                		<label>商铺地址:</label>
			                	</div>
						        <div class="col-sm-2"style="width:15%;" >
							        <select id="province" class="form-control" name="province"></select>
								</div>
						        <div class="col-sm-2" style="width:15%;">
							        <select id="city"  class="form-control" name="city"></select>
								</div>
						        <div class="col-sm-2" style="width:16%;">
							        <select id="county" class="form-control" name="county"></select>
								</div>
						        <div class="col-sm-2" style="width:26%;">
						        	<input id="address" type="text"  class="form-control"  name="address" placeholder="请输入详细地址" required>
							    </div>
						        <div class="col-sm-2" style="width:16%;">
							   		<button type="button" id="map_btn" class="button button-pill button-flat-primary button-tiny"  >地图选择</button>
							    </div>
						    </div>
					    </div>
				    </div>
			    </div>
				</div>
			</div>
			<div class="col-md-6">
				<div class="panel panel-default">
					<div class="panel-heading">
						请上传商家图片
				    </div>
			    	<div class="panel-body" id="img_div">
			    		<div class="col-md-12 img_item_div">
			    		    <div class="col-md-8" style="width:64%;">
								<img id="shareImage_img"  src="" width="40%" height="20%" />
								<input style="display:none;" type="file" name="imgFile" id="shareImage_file" accept=".bmp,.gif,.jpeg,.jpg,.png">
								<input type="hidden" id="img1" name="img1" value="">
								<span class="help-block">单击上传图片,建议图片大小600×300</span>
							</div>
					        <div class="col-md-2" style="width:18%;">
								<button type="button" class="button button-pill button-flat-primary button-tiny" id="shareImage_btn">
								<i class="glyphicon glyphicon-open"></i>添加图片</button>
							</div>
					        <div class="col-md-2" style="width:18%;">
					        	<button type="button"  id="deleteImg" class="pull-right button button-pill button-flat-caution button-tiny">
					        	<span class="glyphicon glyphicon-remove"></span>&nbsp;删除图片</button>
							</div>
							
			    		    <div class="col-md-8" style="width:64%;">
								<img id="shareImage_img2"  src="" width="40%" height="20%" />
								<input style="display:none;" type="file" name="imgFile" id="shareImage_file2" accept=".bmp,.gif,.jpeg,.jpg,.png">
								<input type="hidden" id="img2" name="img2" value="">
								<span class="help-block">单击上传图片,建议图片大小600×300</span>
							</div>
					        <div class="col-md-2" style="width:18%;">
								<button type="button" class="button button-pill button-flat-primary button-tiny" id="shareImage_btn2">
								<i class="glyphicon glyphicon-open"></i>添加图片</button>
							</div>
					        <div class="col-md-2" style="width:18%;">
					        	<button type="button" id="deleteImg2" class="pull-right button button-pill button-flat-caution button-tiny ">
					        	<span class="glyphicon glyphicon-remove"></span>&nbsp;删除图片</button>
							</div>
							
			    		    <div class="col-md-8" style="width:64%;">
								<img id="shareImage_img3"  src="" width="40%" height="20%" />
								<input style="display:none;" type="file" name="imgFile" id="shareImage_file3" accept=".bmp,.gif,.jpeg,.jpg,.png">
								<input type="hidden" id="img3" name="img3" value="">
								<span class="help-block">单击上传图片,建议图片大小600×300</span>
							</div>
					        <div class="col-md-2" style="width:18%;">
								<button type="button" class="button button-pill button-flat-primary button-tiny" id="shareImage_btn3">
								<i class="glyphicon glyphicon-open"></i>添加图片</button>
							</div>
					        <div class="col-md-2" style="width:18%;">
					        	<button type="button" id="deleteImg3" class="pull-right button button-pill button-flat-caution button-tiny">
					        	<span class="glyphicon glyphicon-remove"></span>&nbsp;删除图片</button>
							</div>
							
			    		    <div class="col-md-8" style="width:64%;">
								<img id="shareImage_img4"  src="" width="40%" height="20%" />
								<input style="display:none;" type="file" name="imgFile" id="shareImage_file4" accept=".bmp,.gif,.jpeg,.jpg,.png">
								<input type="hidden" id="img4" name="img4" value="">
								<span class="help-block">单击上传图片,建议图片大小600×300</span>
							</div>
					        <div class="col-md-2" style="width:18%;">
								<button type="button" class="button button-pill button-flat-primary button-tiny" id="shareImage_btn4">
								<i class="glyphicon glyphicon-open"></i>添加图片</button>
							</div>
					        <div class="col-md-2" style="width:18%;">
					        	<button type="button" id="deleteImg4" class="pull-right button button-pill button-flat-caution button-tiny">
					        	<span class="glyphicon glyphicon-remove"></span>&nbsp;删除图片</button>
							</div>
			    	    </div>
			    	</div>
		    	</div>
		    </div>
		</form>	
  </div>
  <div class="row">
	  <div class="col-md-12" style="margin-top:20px;">
			<div class="col-md-5">
			</div>
			<div class="col-md-7">
				<div class="form-group">
					<input type="submit" id="createPartner" class="btn btn-primary" value="添加商家">
					<span>&emsp;&emsp;</span>
	    			<input type="button" class="btn btn-default" onclick="window.location.href = '${ctx}/partner/list/${categoryAlias}';" value="返回">
				</div>
			</div>
		</div>
  </div>
<div class="modal fade" id="dialog_modifyCash">
   <div class="modal-dialog">
     <div class="modal-content">
    	<div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        	<h4 class="modal-title">选择商家地址</h4>
        </div>
	    <div class="modal-body">
      	 <div id="allmap" style="z-index: 99999; height:500px;">
		 </div>
     	</div>
     </div>
  </div>
</div>
</@override>
<@override name="footer">
<script type="text/javascript" language="javascript">
		window.daijia = {ctx : '${ctx}',address : '${address?if_exists}'};
</script>
<script src="${ctx}/assets/js/region_select.js"></script>
<script src="//api.map.baidu.com/api?v=2.0&ak=AuNk3YS21DSmHEEvIFDf9dbD" type="text/javascript"></script> 
<script src="${ctx}/assets/js/jquery.autocomplete.min.js"></script>
<script src="${ctx}/assets/js/ajaxfileupload.js"></script>
<script src="${ctx}/assets/js/partner/create.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
			new PCAS('province','city','county');
			//图片上传
			$("#shareImage_img").click(function(){
				$("#shareImage_file").click();
			});
			$("#shareImage_btn").click(function(){
				$("#shareImage_file").click();
			});
			$(document).on('change','#shareImage_file',function(){
				if($.trim($(this).val())){
				 	$.ajaxFileUpload({
		                url:'${ctx}/common/uploadimg',
		                secureuri:false,
		                fileElementId:'shareImage_file',
		                dataType: 'json',
		                success: function (result, textStatus) {
		                	if(result.success){
		                		$.scojs_message("上传成功", $.scojs_message.TYPE_OK);
		                    	$("#shareImage_img").attr("src","${ctx}/"+result.url);
		                    	$("#img1").val(result.url);
		                	}else{
		                		$.scojs_message(result.msg, $.scojs_message.TYPE_ERROR);
		                	}
		                }
		            });
				}
			});
			//第二张图片上传
			$("#shareImage_img2").click(function(){
				$("#shareImage_file2").click();
			});
			$("#shareImage_btn2").click(function(){
				$("#shareImage_file2").click();
			});
			$(document).on('change','#shareImage_file2',function(){
				if($.trim($(this).val())){
				 	$.ajaxFileUpload({
		                url:'${ctx}/common/uploadimg',
		                secureuri:false,
		                fileElementId:'shareImage_file2',
		                dataType: 'json',
		                success: function (result, textStatus) {
		                	if(result.success){
		                		$.scojs_message("上传成功", $.scojs_message.TYPE_OK);
		                    	$("#shareImage_img2").attr("src","${ctx}/"+result.url);
		                    	$("#img2").val(result.url);
		                	}else{
		                		$.scojs_message(result.msg, $.scojs_message.TYPE_ERROR);
		                	}
		                }
		            });
				}
			});
			//第三张图片上传
			$("#shareImage_img3").click(function(){
				$("#shareImage_file3").click();
			});
			$("#shareImage_btn3").click(function(){
				$("#shareImage_file3").click();
			});
			$(document).on('change','#shareImage_file3',function(){
				if($.trim($(this).val())){
				 	$.ajaxFileUpload({
		                url:'${ctx}/common/uploadimg',
		                secureuri:false,
		                fileElementId:'shareImage_file3',
		                dataType: 'json',
		                success: function (result, textStatus) {
		                	if(result.success){
		                		$.scojs_message("上传成功", $.scojs_message.TYPE_OK);
		                    	$("#shareImage_img3").attr("src","${ctx}/"+result.url);
		                    	$("#img3").val(result.url);
		                	}else{
		                		$.scojs_message(result.msg, $.scojs_message.TYPE_ERROR);
		                	}
		                }
		            });
				}
			});
			//第四张图片上传
			$("#shareImage_img4").click(function(){
				$("#shareImage_file4").click();
			});
			$("#shareImage_btn4").click(function(){
				$("#shareImage_file4").click();
			});
			$(document).on('change','#shareImage_file4',function(){
				if($.trim($(this).val())){
				 	$.ajaxFileUpload({
		                url:'${ctx}/common/uploadimg',
		                secureuri:false,
		                fileElementId:'shareImage_file4',
		                dataType: 'json',
		                success: function (result, textStatus) {
		                	if(result.success){
		                		$.scojs_message("上传成功", $.scojs_message.TYPE_OK);
		                    	$("#shareImage_img4").attr("src","${ctx}/"+result.url);
		                    	$("#img4").val(result.url);
		                	}else{
		                		$.scojs_message(result.msg, $.scojs_message.TYPE_ERROR);
		                	}
		                }
		            });
				}
			});
			
	});
</script>
</@override>
<@extends name="../layout.ftl"/>